package PKGAME;

import java.util.Random;

public class Role {
    private String name;
    private int blood;
    private char sex;
    private String face;
    String[] boyfaces={"风流倜傥","气宇轩昂","凶神恶煞","肝胆雄心","信心满满"};
    String[] girlfaces={"沉鱼落雁","亭亭玉立","美轮美奂","娇娇滴滴","闭月羞花"};
    public Role() {
    }

    public Role(String name, int blood,char sex) {
        this.name = name;
        this.blood = blood;
        this.sex = sex;
        setFace(sex);
    }
    public char getSex() {
        return sex;
    }
    public void setSex(char sex) {
        this.sex = sex;
    }

    public String getFace() {
        return face;
    }

    public void setFace(char sex) {
        Random r = new Random();
        if(sex=='男'){
            int index =r.nextInt(boyfaces.length);
            this.face = boyfaces[index];

        }
        else if(sex=='女'){
            int index = r.nextInt(girlfaces.length);
            this.face = girlfaces[index];
        }
        else {
            this.face = "平和";
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getBlood() {
        return blood;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }

    public void attack(Role role) {
        Random r = new Random();
        int hurt = r.nextInt(20)+1;
        int remainblood = role.getBlood()-hurt;
        remainblood = remainblood< 0 ? 0:remainblood;
        role.setBlood(remainblood);
        System.out.println(this.face+"的"+this.name+"向"+role.name+"发起了攻击，"+"对"+role.name+"造成了"+hurt+"点伤害,"+role.name+"还剩下"+
                remainblood+"点血");
    }
}